package org.scauinfo.fpos.vo;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * User entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "user", catalog = "db_fpos")
public class User implements java.io.Serializable {

	// Fields

	private Integer id;
	private Userrole userrole;
	private String userId;
	private String username;
	private String account;
	private String password;
	private String gender;
	private String telephone;
	private Set<Saleorder> saleorders = new HashSet<Saleorder>(0);

	
	/** default constructor */
	public User(Userrole userrole) {
		this.userrole=userrole;
	}
	// Constructors

	/** default constructor */
	public User() {
	}

	/** minimal constructor */
	public User(String userId, String username, String account, String password) {
		this.userId = userId;
		this.username = username;
		this.account = account;
		this.password = password;
	}

	/** full constructor */
	public User(Userrole userrole, String userId, String username,
			String account, String password, String gender, String telephone,
			Set<Saleorder> saleorders) {
		this.userrole = userrole;
		this.userId = userId;
		this.username = username;
		this.account = account;
		this.password = password;
		this.gender = gender;
		this.telephone = telephone;
		this.saleorders = saleorders;
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "permission_id",referencedColumnName="role_id")
	public Userrole getUserrole() {
		return this.userrole;
	}

	public void setUserrole(Userrole userrole) {
		this.userrole = userrole;
	}

	@Column(name = "user_id", nullable = false)
	public String getUserId() {
		return this.userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	@Column(name = "username", nullable = false)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "account", nullable = false)
	public String getAccount() {
		return this.account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	@Column(name = "password", nullable = false)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "gender")
	public String getGender() {
		return this.gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	@Column(name = "telephone")
	public String getTelephone() {
		return this.telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Saleorder> getSaleorders() {
		return this.saleorders;
	}

	public void setSaleorders(Set<Saleorder> saleorders) {
		this.saleorders = saleorders;
	}

}